#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int N=2e5+10;
#define INF 0x3f3f3f3f;
typedef long long int ll;
#define close(); std::ios::sync_with_stdio(false);cin.tie(0),cout.tie(0);
//----------------------------------------------------------------------------//
int n;
int a[60];
int a2[60];
void solve()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i],a2[i]=a[i];
	
	sort(a2+1,a2+1+n);
	
	vector<vector<int>> v1;
	for(int i=1;i<n;i++)
	{
		if(a[i]!=a2[i])
		{
			vector<int> ans;
			int head=i;
			int ass=i+1;
			int t=a[i];
			for(int j=i;j<n;j++)
			{
				if(a[j+1]==a2[i])
				{
					ass=j+1;
					a[j+1]=t;
					break;
				}
				int tt=a[j+1];
				a[j+1]=t;
				t=tt;
			}
			a[i]=a2[i];
			
			//cout<<head<<" "<<ass<<" "<<1<<'\n';
			ans.push_back(head);
			ans.push_back(ass);
			v1.push_back(ans);
		}
	}
	cout<<v1.size()<<'\n';
	for(auto &it:v1)
	{
		for(auto&k:it)
		{
			cout<<k<<" ";
		}
		cout<<it[1]-it[0]<<'\n';
	}


}

int main()
{
	close();
	int T; cin>>T;
	while (T--) solve();
	return 0;
}

